using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Xml;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using OR.Lazarus.Library.CPP.Types;
using System.IO;
using OR.Reuse.Persistence;

namespace OR.Lazarus.Library.Tests.CPP
{
	/// <summary>
	/// Summary description for TypesTests
	/// </summary>
	[TestClass]
    [Ignore]
	public class TypesTests : CPPTestBase< TypeMapDetail >
	{
		public TypesTests()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		#region Additional test attributes
		//
		// You can use the following additional attributes as you write your tests:
		//
		// Use ClassInitialize to run code before running the first test in the class
		// [ClassInitialize()]
		// public static void MyClassInitialize(TestContext testContext) { }
		//
		// Use ClassCleanup to run code after all tests in a class have run
		// [ClassCleanup()]
		// public static void MyClassCleanup() { }
		//
		// Use TestInitialize to run code before running each test 
		// [TestInitialize()]
		// public void MyTestInitialize() { }
		//
		// Use TestCleanup to run code after each test has run
		// [TestCleanup()]
		// public void MyTestCleanup() { }
		//
		#endregion

		[TestInitialize()]
		public void CPP_Types_TestInitialize()
		{
			this.InitializePersistence();
			this.InitializeDetail( "Types.xml" );
		}

		[TestMethod]
		public void CPP_Types_Load()
		{
			TypeDetail vTypeDetail;

			// Validate contents
			Assert.IsTrue( mDetail.Types.Count == 3, String.Format( ErrorInvalidCount, "Types", 3, mDetail.Types.Count ) );

			vTypeDetail = mDetail.Types[ "vt:string" ];

			Assert.IsNotNull( vTypeDetail );

			Assert.IsTrue( vTypeDetail.Names.Count == 3, String.Format( ErrorInvalidCount, "Type Names", 3, vTypeDetail.Names.Count ) );
		}

		[TestMethod]
		public void CPP_Types_Resolve_Type()
		{
			string vResolvedType = null;

			vResolvedType = mDetail.ResolveContextType( "vt:string", "SQL2k" );

			Assert.IsTrue( vResolvedType == "VARCHAR", "Invalid Type Resolution for 'SQL2k' context of 'vt:string'.  Expected 'VARCHAR', found '" + vResolvedType + "'." );
		}

		[TestMethod]
		[ExpectedException( typeof( ApplicationException ) )]
		public void CPP_Types_Resolve_BadType()
		{
			string vResolvedType = null;

			vResolvedType = mDetail.ResolveContextType( "vt:unsupported", "SQL2k" );
		}

		[TestMethod]
		[ExpectedException( typeof( ApplicationException ) )]
		public void CPP_Types_Resolve_BadContext()
		{
			string vResolvedType = null;

			vResolvedType = mDetail.ResolveContextType( "vt:string", "unsupported" );
		}
	}
}
